From: Keir Fraser Date: Thu, 17 Jan 2008 12:59:10 +0000 (+0000) Subject: hvm: Allocate an unmapped guard page to separate ordinary low RAM X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14445^2~35 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=e0413522fde7f6d04ece91c582fadfd6a2fd86c4;p=xen.git hvm: Allocate an unmapped guard page to separate ordinary low RAM from special pages (ioreq, xenstore, etc). This will stop some probe functions (e.g., embedded in memtest) from stomping on the special pages. Signed-off-by: Keir Fraser --- diff --git a/tools/libxc/xc_hvm_build.c b/tools/libxc/xc_hvm_build.c index cb4bf32fdf..296648a436 100644 --- a/tools/libxc/xc_hvm_build.c +++ b/tools/libxc/xc_hvm_build.c @@ -77,13 +77,19 @@ static void build_e820map(void *e820_page, unsigned long long mem_size) e820entry[nr_map].type = E820_RESERVED; nr_map++; - /* Low RAM goes here. Remove 3 pages for ioreq, bufioreq, and xenstore. */ + /* + * Low RAM goes here. Remove 4 pages for: ioreq, bufioreq, and xenstore. + * 1. Guard page. + * 2. Buffered ioreq. + * 3. Xenstore. + * 4. Normal ioreq. + */ e820entry[nr_map].addr = 0x100000; - e820entry[nr_map].size = mem_size - 0x100000 - PAGE_SIZE * 3; + e820entry[nr_map].size = mem_size - 0x100000 - PAGE_SIZE * 4; e820entry[nr_map].type = E820_RAM; nr_map++; - /* Explicitly reserve space for special pages (ioreq and xenstore). */ + /* Explicitly reserve space for special pages. */ e820entry[nr_map].addr = mem_size - PAGE_SIZE * 3; e820entry[nr_map].size = PAGE_SIZE * 3; e820entry[nr_map].type = E820_RESERVED; @@ -244,6 +250,15 @@ static int setup_guest(int xc_handle, else shared_page_nr = (v_end >> PAGE_SHIFT) - 1; + /* Free the guard page that separates low RAM from special pages. */ + rc = xc_domain_memory_decrease_reservation( + xc_handle, dom, 1, 0, &page_array[shared_page_nr-3]); + if ( rc != 0 ) + { + PERROR("Could not deallocate guard page for HVM guest.\n"); + goto error_out; + } + /* Paranoia: clean pages. */ if ( xc_clear_domain_page(xc_handle, dom, shared_page_nr) || xc_clear_domain_page(xc_handle, dom, shared_page_nr-1) ||